package com.my.controller;

import com.my.request.WecomConfigChangeReq;
import com.my.request.WecomConfigQueryReq;
import com.my.request.WecomConfigUpdateReq;
import com.my.response.WecomConfigDetailResponse;
import com.my.response.WecomConfigResponse;
import com.my.result.PageResult;
import com.my.result.Result;
import com.my.service.WecomConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author sjx
 * @date 2025/2/13 10:11
 */
@Slf4j
@RestController
@RequestMapping("/wecomConfig")
public class WecomConfigController {

    @Autowired
    private WecomConfigService wecomConfigService;

    @PostMapping("/list")
    public Result<PageResult<WecomConfigResponse>> list(@RequestBody @Valid WecomConfigQueryReq query) {
        PageResult<WecomConfigResponse> page = wecomConfigService.getPage(query);
        return Result.ok(page);
    }

    @GetMapping("/detail/{wecomConfigId}")
    public Result<WecomConfigDetailResponse> getById(@PathVariable Long wecomConfigId) {
        WecomConfigDetailResponse info = wecomConfigService.getInfo(wecomConfigId);
        return Result.ok(info);
    }

    @PostMapping("/updateVal")
    public Result<Void> updateVal(@RequestBody @Valid WecomConfigUpdateReq request) {
        wecomConfigService.updateInfo(request);
        return Result.ok();
    }

    @PostMapping("/changeStatus")
    public Result<Void> changeStatus(@RequestBody @Valid WecomConfigChangeReq request) {
        wecomConfigService.changeStatus(request);
        return Result.ok();
    }

}
